package com.bw.task.activity;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.content.Intent;
import android.os.Bundle;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bw.task.MainActivity;
import com.bw.task.R;
import com.uuzuche.lib_zxing.activity.CaptureActivity;
import com.uuzuche.lib_zxing.activity.CodeUtils;

public class EWMActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ewmactivity);

        startActivityForResult(new Intent(EWMActivity.this, CaptureActivity.class),100);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable @org.jetbrains.annotations.Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode==100){
            Bundle extras = data.getExtras();
            if (extras!=null){
                if (CodeUtils.RESULT_SUCCESS==extras.getInt(CodeUtils.RESULT_TYPE)){
                    String string = extras.getString(CodeUtils.RESULT_STRING);
                    ToastUtils.showShort(string);
                    LogUtils.i(string);
                    startActivity(new Intent(EWMActivity.this, MainActivity.class));
                }else {
                    ToastUtils.showShort("解析失败");
                }
            }
        }
    }
}